from flaskLogin import create_app
from flask_migrate import Migrate
from flaskLogin.extensions import db
from flaskLogin.models import Account

import uuid

app = create_app()
migrate = Migrate(app, db)


@app.cli.command()  # pipenv run flask fakeuser
def fakeuser():
    user = Account()
    user.userid = '00001'
    user.set_password('helloflask')
    user.alternative_id = uuid.uuid1()
    user.department = 'it.develop'
    user.username = 'L.Gen'
    user.is_admin = True
    db.session.add(user)
    db.session.commit()


'''
迁移数据库
1.pipenv run flask db init (第一次）
2.pipenv run flask db migrate
3.pipenv run flask db upgrade
'''
